import * as React from "react";
import { Form, Row, Col, Input, Button, Icon, DatePicker, Select, Table, message, Modal, Spin } from 'antd';
import * as moment from 'moment';
import './index.scss';
import { FormComponentProps } from 'antd/lib/form/Form' //获取form表单的interface
const { Option } = Select;
const { TextArea } = Input;
const { confirm } = Modal;
import Api from '../../config/api';
import { ListGUID } from '../../config/ListGuid';
import { number } from "echarts";
import { dynamicsService } from "../../../../../services/services";
import { isHavePermission, isHavePathPermission } from '../../utils/utils';
// 检索
import { CAMLFilter, CAMLCompare, CamlQuery, SPDataType, CamlParam, CamlOrderBy } from './../../config/CAMLHelper';
const layout = {
  labelCol: {
    span: 4,

  },
  wrapperCol: {
    offset: 1,
    span: 19,
  },
}
const phoneValidator = (rule: any, value: any, callback: any) => {
  if (!value) {
    callback('请输入！')
  }
  // 必须总是返回一个 callback，否则 validateFields 无法响应
  callback();
}
// 测试代码，调试API使用
class AddContractVersion extends React.Component<any, any> {
  constructor(props: any & FormComponentProps) {
    super(props);
  }

  state = {
    AuthorId: JSON.parse(sessionStorage.getItem('userInfo')).Id,
    AuthorName: JSON.parse(sessionStorage.getItem('userInfo')).Title,
    currentForm: null,
    loading: false,
    contractId: '',
    backPage: '', //返回的页面
    //资质
    qualificationsList: ['有', '无', '无需资质'],
    //表单数据对象
    form: {
      // 法务受理日
      date: null,
      // 法务最后回答日
      date1: null,
      // 语言
      language: null,
      // 合同名称
      theContract: null,
      // 关键词1
      keywords1: null,
      // 关键词2
      keywords2: null,
      // 合同修改性质
      modification: [],
      // 相对方
      otherSide: null,
      // 社内依赖者名
      community: undefined,
      // 其他
      other: null,
      // 合同编号
      contract: '',
      // 决裁编号
      cutNumber: '',
      // 审查担当
      reviewOn: null,
      // 文件保存
      file: null,

      //下拉选择
      //问题
      problem: undefined,
      //性质
      nature: undefined,
      //期限
      term: undefined,
      //重要性
      importance: undefined,
      //我方
      we: undefined,
      //资质
      qualifications: '无',
      //律师审查
      examination: 1,
      //审查担当
      reviewOnxuan: [],
      //所属公司
      company: undefined,
      //所属部门
      department: undefined,
      //审查担当
      reviewOnxuans: undefined,
      //弹框
      contracts: '',
      reviewOns: null,
      theContracts: null,
      wes: undefined,
      otherSides: null,
      enclosurelist: [],
      proposal: '无',//申请书
    },
    //问题
    problemList: [],
    // 所属公司
    ofAffiList: [],
    //所属部门
    departmentList: [],
    // 合同性质
    natureList: [],
    //合同期限
    termList: [],
    //合同重要性
    importanceList: [],
    //律师审查
    LawyerList: [],
    //审查担当
    personreviewList: [],
    //审查担当
    reviewOnxuan: [],
    //修改性质
    modificationList: [],
    //依赖者
    communityList: [],
    //状态
    variable: '',
    //变量
    JudgmentVariable: '',
    //我方
    weList: [],
    JudgmentVariableID: number,

    //弹框
    visible: false,
    //数据
    datas: null,
    disabled: false,
    pidisabled: true,
    fujian: null,
    wedisabled: false,
  }
  onBlurs(e) {
    let paten = /^[A-Za-z]+$/g;
    if (!paten.test(this.state.form.we)) {
      message.warning('请输入字母', 2);
      setTimeout(() => {
        this.setState({
          form: {
            ...this.state.form,
            we: undefined,
          }
        })
        
        this.props.form.setFieldsValue({
          text: undefined,
        })
      }, 100)
      return;
    }
    
    this.props.form.setFieldsValue({
      text: this.state.form.we
    })
  }
  // 输入框改变赋值
  change(e, key) {
    
    if (key == 'we') {
      this.setState({
        form: {
          ...this.state.form,
          [key]: e.target.value.toUpperCase()
        }
      })
    } else if (key == 'date' || key == 'date1') {
      this.setState({
        form: {
          ...this.state.form,
          [key]: e.format('YYYY-MM-DD')
        }
      })
    } else {
      this.setState({
        form: {
          ...this.state.form,
          [key]: e.target.value
        }
      })
    }


  }

  // 下拉框改变赋值
  handleSelectChange(e, key) {
    this.setState({
      form: {
        // key: e,
        ...this.state.form,
        [key]: e
      }
    })
  }
  // 下拉框改变赋值
  handleSelectChanges(e, v, key) {
    var array = []
    var arrays = []
    v.forEach(element => {
      array.push(element.key)
      arrays.push(`${element.props.value}#${element.props.children}`)
    });
    this.setState({
      form: {
        ...this.state.form,
        reviewOn: array.join(","),
        reviewOnxuans: arrays.join(';'),
        [key]: e
      }
    })
  }

  allowClear(e, key) {
    const { value } = e.target;
    
    if (!value && e.type !== 'change') {
      // do something
      this.setState({
        form: {
          ...this.state.form,
          [key]: undefined,
          company: undefined,
          //所属部门
          department: undefined,
        }
      })
    }else {
      this.setState({
        form: {
          ...this.state.form,
          [key]: e.target.value
        }
      })
    }
  }


  loseFocus(e, key) {
    let array = JSON.parse(sessionStorage.getItem('AADUsers'));
    let size: any = []
    for (let index = 0; index < array.length; index++) {
      if (e.target.value == array[index].displayName) {
        size.push(array[index])
      }
    }

    if (size.length == 0) {
      this.setState({
        form: {
          ...this.state.form,
          [key]: e.target.value,
          company: undefined,
          //所属部门
          department: undefined,
        }
      })
    } else {
      this.setState({
        form: {
          ...this.state.form,
          [key]: size[0].displayName,
          company: size[0].companyName,
          //所属部门
          department: size[0].department,
        }
      })
    }

  }



  // 下拉框改变赋值
  handleSelectChangess(e, v, key) {
    if (e != undefined) {
      this.props.form.setFieldsValue({
        company: v.props.children[2],
        //所属部门
        department: v.props.children[4],
      })
    } else {
      this.props.form.setFieldsValue({
        company: undefined,
        //所属部门
        department: undefined,
      })
    }
  }
  //禁止选择年
  disabledDate = time => {
    if (this.state.wedisabled) {
      var timeYear = time.get('year');  //当前年
      var currentYear = moment(this.state.form.date).format('YYYY'); //今年
      return timeYear != currentYear;
    } else {

    }
  };
  //提交按钮触发
  submit = async (e) => {
    
    await this.setState({
      variable: e == '作废' ? '废弃' : e == '提交' ? '有效' : '草稿'
    })
    
    if (e == '作废') {
      let file = this.props.form.getFieldsValue(['file']).file
      let array = await Api.getFiles(ListGUID.ContractLibRelativeUrl + '/' + file)
      if (array.length != 0) {
        message.warning(`存在附件,请先删除附件`, 2)
        return;
      }
    }
    if (e == '保存草稿') {
      this.warning(e, this.props.form.getFieldsValue(), '保存草稿')
    } else {
      this.props.form.validateFields((err, values) => {
        
        let msg = '';
        if (e == '提交') {
          msg = '保存';
        } else if (e == '作废') {
          msg = e;
        }
        if (!err) {
          if (this.state.wedisabled) {
            this.warning(e, values, msg)
          } else {
            this.warning(e, values, msg)
            // if (this.state.disabled) {
            //   this.warning(e, values, msg)
            // } else {
            //   message.warning('请先匹配编号!', 2)
            // }
          }


        } else {
          
        }
      });
    }

  };
  //提示框
  warning = (e, values, msg = '提交') => {
    if(!this.state.currentForm && e === '提交') {
      message.warning('请先匹配合同版本号再提交');
      return
    }
    confirm({
      centered: true,
      title: '温馨提示',
      content: `是否` + msg + `?`,
      okText: '确认',
      cancelText: '取消',
      onOk: () => { this.getSubmit(e,values) }
    });
  };
  // 关闭按钮触发
  shutDown = async () => {
    let MinistryJustice = await Api._isLegalDepartment();
    confirm({
      centered: true,
      title: '温馨提示',
      content: `是否关闭该页面,关闭该页面未提交数据清空?`,
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        // location.href = "#/Dashboard" 
        // 判断是否为法务部
        // MinistryJustice = false
        if (MinistryJustice) { location.href = "#/Dashboard" } else {
          location.href = "#/DocumentLibrary"
        }
      }
    });
  };
  getFilds = () => {
    if (this.props.form.getFieldsValue(['file']).file) {
      // const filedom = document.getElementById('fileUploadInput');
      // filedom.click()
      dynamicsService.UpdateListFileNames({dataid: this.state.currentForm.id, listguid: ListGUID.StandingBook, fileaddress: this.state.currentForm.FileAddress}).then(() => {
        if (isHavePermission('AddContractVersion/todocumentlibrary')) {
          if(this.state.form.contract.indexOf('DUMY') === -1) {
            window.open(ListGUID.Domain + ListGUID.ContractLibRelativeUrl + '/' + this.props.form.getFieldsValue(['file']).file)
          } else {
            window.open(ListGUID.Domain + ListGUID.DumyLibRelativeUrl + '/' + this.props.form.getFieldsValue(['file']).file)
          }
          
        }
      })
      
      
      return;
    }
    message.warning('暂无上传路径', 2)
  }
  private setButtonsEventHandlers(): void {
    let fileUpload = document.getElementById('fileUploadInput');
    if (fileUpload) {
      fileUpload.addEventListener('change', () => {
        this.fileinputChange(fileUpload);
      });
    }
  }
  //循环
  getloop = async (item) => {
    var fileData = item;
    let fSize = fileData.size
    let fileName = fileData.name
    var maxSize = 20 * 1024 * 1024; //限制20M
    if (fSize > maxSize) {
      message.warning(`${fileName}文件内容太大，上传失败，请检查文件后重新上传!`, 2)
      return;
    }
    //判断空文件
    if (fSize == 0) {
      //空文件
      message.warning(`${fileName}的文件内容为空，请检查文件后重新上传!`, 2)
      return;
    }

    //判断文件名称合法
    if (fileName.indexOf('.') > -1 || fileName.indexOf('%') > -1 || fileName.indexOf('#') > -1 || fileName.indexOf('+') > -1) {
      //排除 .
      if (fileName.indexOf('.') > -1) {
        let firstCodePosition = fileName.indexOf('.');
        let lastCodePosition = fileName.lastIndexOf('.');
        if (firstCodePosition != lastCodePosition) {
          //位置不同，有多个 
          message.warning(`${fileName}文件名称包含特殊字符‘.’，不允许上传，请修改文件名称后重新上传`, 2)
          return;
        }
      }

      //排除 % # +
      if (fileName.indexOf('%') > -1 || fileName.indexOf('#') > -1 || fileName.indexOf('+') > -1) {
        message.warning(`${fileName}文件名称包含特殊字符‘%、#、+’，不允许上传，请修改文件名称后重新上传`, 2)
        return;
      }
    }

    //判断文件名称超长       
    if (fileName.length >= 44) {
      message.warning(`${fileName}文件名称超过40个字符，请修改文件名称后重新上传`, 2)
      return;
    }
    let file = this.props.form.getFieldsValue(['file']).file
    let array = await Api.getFiles(ListGUID.ContractLibRelativeUrl + '/' + file)
    if (array.length != 0) {
      for (let j = 0; j < array.length; j++) {
        if (fileName == array[j].Name) {
          message.warning(`${fileName}文件名已在申请中或文档中心已存在，请勿重复申请`, 2)
          return;
        }
      }
    }
    let url = ListGUID.ContractLibRelativeUrl + '/' + file
    let parme = Api._addfiles(fileData, url)
    if (parme) {
      var arrays = [];
      arrays.push(fileName)
      arrays = this.state.form.enclosurelist.concat(arrays)
      this.setState({
        form: {
          ...this.state.form,
          enclosurelist: arrays
        }
      })
      message.success(`${fileName}文件上传成功`, 2)
      
    }
  }
  //上传附件
  fileinputChange = async (event) => {
    for (let i = 0; i < event.files.length; i++) {
      this.getloop(event.files[i])
    }
  }
  //动态更新绑定数据
  public async componentDidMount() {
    this.setState({
      AuthorId: JSON.parse(sessionStorage.getItem('userInfo')).Id,
      AuthorName: JSON.parse(sessionStorage.getItem('userInfo')).Title,
    })
    isHavePathPermission()
    this.getTest();// 测试代码，调试API使用
    let title = this.props.location.state
    if (title != undefined) {
      this.getedit(title.id)
      this.setState({
        contractId: title.id,
        backPage: title.backPage
      })
    }
    this.setButtonsEventHandlers()
    let token = await dynamicsService.getToken()
    // let getlist = await dynamicsService.getusers(token.data.data)
    // this.setState({
    //   communityList: getlist.value 
    // })
  }
  //初始化数据
  initialization = () => {
    let { form } = this.state;
    form = {
      // 法务受理日
      date: null,
      // 法务最后回答日
      date1: null,
      // 语言
      language: null,
      // 合同名称
      theContract: null,
      // 关键词1
      keywords1: null,
      // 关键词2
      keywords2: null,
      // 合同修改性质
      modification: [],
      // 相对方
      otherSide: null,
      // 社内依赖者名
      community: undefined,
      // 其他
      other: null,
      // 合同编号
      contract: '',
      // 决裁编号
      cutNumber: '',
      // 审查担当
      reviewOn: null,
      // 文件保存
      file: null,

      //下拉选择
      //问题
      problem: undefined,
      //性质
      nature: undefined,
      //期限
      term: undefined,
      //重要性
      importance: undefined,
      //我方
      we: undefined,
      //资质
      qualifications: '无',
      //律师审查
      examination: 1,
      //审查担当
      reviewOnxuan: [],
      //所属公司
      company: undefined,
      //所属部门
      department: undefined,
      //审查担当
      reviewOnxuans: undefined,

      contracts: '',
      reviewOns: null,
      theContracts: null,
      wes: undefined,
      otherSides: null,
      enclosurelist: [],
      proposal: '无',
    }
    this.setState({
      form,
      disabled: false,
      wedisabled: false
    })
    this.props.form.resetFields()
  };
  //确定弹框
  handleOk = () => {

    this.setState({
      visible: false,
    });
  };
  //失去焦点
  onBlur = async () => {
    let yan = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*$/
    let contract = this.props.form.getFieldsValue(['contract']).contract
    if (contract.length > 8) {
      if (yan.test(contract)) {
        // var param1 = {
        //   Guid: ListGUID.StandingBook, //台账
        //   Filter: `Title eq '${contract}-0' and ContractStatus eq '有效'`
        // };
        // let Person = await Api._getModel(param1);
        let params: any = [
          {
            logic: "and",
            where: [
              {
                key: 'Title',
                filterType: "Eq",
                value: `${contract}-0`
              },
              {
                key: 'ContractStatus',
                filterType: "Eq",
                value: `有效`
              }
            ]
          }
        ];
        let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
        let Person = data.data;
        if (Person.length != 0) {
          let { form } = this.state;
          form.contracts = Person[0].Title.substring(0, Person[0].Title.lastIndexOf('-'))
          form.reviewOns = Person[0].ReviewOnID
          form.theContracts = Person[0].ContractName
          form.wes = Person[0].Our
          form.otherSides = Person[0].Counterparty

          this.setState({
            visible: true,
            datas: Person[0],
            form,
            pidisabled: false,
          })
        } else {
          message.warning('该编号没有查到采番数据或该编号已作废', 2)
        }
      } else {
        message.warning('请检查输入编号是否存在特殊符号!', 2)
      }
    } else {
      message.warning('请输入正确的编号!', 2)
    }
  }
  public render(): React.ReactElement {
    const { getFieldDecorator } = this.props.form;
    return (
      <div className='box'>
        <Spin spinning={this.state.loading}>
        <div className='box_content'>
          <Row align="middle" justify="end">
            <Col span={24}>
              <div className='flex'>
                <div className="heTong"></div>
                <div className='het'>合同版本号</div>
              </div>
            </Col>
          </Row>
          <Row type="flex" justify="end">
            <Col span={13}>
            </Col>
            {
                isHavePermission('AddContractVersion/abandon') ?  <Col span={1} ><Button type="default" className="Button_1" disabled={this.state.form.contract.indexOf('DUMY') !== -1  ? true : false} onClick={() => { this.submit("作废") }}>作废</Button></Col> : null
              }
            {
                isHavePermission('AddContractVersion/submit') ? <Col span={1} offset={1}><Button type="primary" className="Button_2" onClick={() => { this.submit("提交") }}>提交</Button></Col> : null
              }
            {
                isHavePermission('AddContractVersion/draft') ? <Col span={1} offset={1}><Button type="primary" className="Button_3" disabled={this.state.form.contract && this.state.form.contract.indexOf('DUMY') === -1 ? true : false} onClick={() => { this.submit("保存草稿") }}>草稿</Button></Col> : null
              }
            {
                isHavePermission('AddContractVersion/close') ? <Col span={1} offset={1}><Button type="primary" onClick={this.shutDown}>关闭</Button></Col> : null
              }
            {
              this.state.contractId != '' ? <Col span={1} offset={1}> <Button type="primary" onClick={()=>{ this.props.history.push({pathname: this.state.backPage, state: {isBack: 1}}) }}>返回</Button>
          
        </Col> : ''
            }
            
          </Row>
          <div style={{ width: '100%', height: '20px' }}></div>
          <Form {...layout} name='login' layout="inline">
            <Row type="flex" align='middle'>
              <Col span={11}>
                <Form.Item label='合同编号' labelAlign="right">
                  {
                    getFieldDecorator('contract', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.contract
                    })(<Input allowClear onBlur={this.onBlur} style={{ textTransform: 'uppercase' }} disabled={this.state.disabled} placeholder="请输入" />)
                  }
                </Form.Item>
              </Col>
              <Col span={2}>
                <Form.Item label='-N' className="FormItem ">
                  {
                    isHavePermission('AddContractVersion/match') ? <Button  style={{marginLeft: '0px'}} type="primary" className="Button_3" onClick={this.generateNumber} disabled={this.state.pidisabled}>匹配</Button> : null
                  }

                </Form.Item>
              </Col>
              <Col span={11} offset={0}>
                <Form.Item label='语言' labelAlign="right">
                  {
                    getFieldDecorator('language', {
                      initialValue: this.state.form.language
                    })(<Input allowClear placeholder="请输入内容"  onChange={(event) => { this.change(event, "language") }} />)
                  }
                  {/* <Input allowClear placeholder="请输入内容" value={this.state.form.language} onChange={(event) => { this.change(event, "language") }}/> */}
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='法务受理日' labelAlign="right">
                  {
                    getFieldDecorator('date', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.date
                    })(<DatePicker allowClear style={{ width: '100%' }}  onChange={(event) => { this.change(event, "date") }} placeholder="请选择年份" format='YYYY/MM/DD' />)
                  }

                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='问题' labelAlign="right">
                  {
                    getFieldDecorator('problem', {
                      initialValue: this.state.form.problem
                    })(<Select allowClear
                      placeholder="请选择"
                      onChange={(event) => { this.handleSelectChange(event, "problem") }}
                    >
                      {
                        this.state.problemList.map(element => {
                          return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                  {/* <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.problem}
                    onChange={(event) => { this.handleSelectChange(event, "problem") }}
                  >
                    {
                      this.state.problemList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='法务最后回答日' labelAlign="right">
                  {
                    getFieldDecorator('date1', {
                      initialValue: this.state.form.date1
                    })(<DatePicker allowClear style={{ width: '100%' }} placeholder="请选择年份" format='YYYY/MM/DD' onChange={(event) => { this.change(event, "date1") }} />)
                  }
                  {/* <DatePicker allowClear  value={this.state.form.date1 == null? this.state.form.date1 : moment(this.state.form.date1)} style={{ width: '100%' }} placeholder="请选择年份" onChange={this.onChange1} format='YYYY/MM/DD' /> */}
                  {/* <DatePicker allowClear  style={{ width: '100%' }} placeholder="请选择年份" /> */}
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                {/* <Form.Item label='合同性质' labelAlign="right">
                  <Select allowClear 
                      showSearch
                      placeholder="请选择"
                      optionFilterProp="children"
                      onChange={this.onSelectChange}
                      style={{width: '100%'}}
                    >
                      {
                        this.nature.map(element => {
                          return <Option value={element}>{element}</Option>
                        })
                      }
                    </Select>
                </Form.Item> */}
                <Form.Item label='合同性质' labelAlign="right">
                  {
                    getFieldDecorator('nature', {
                      initialValue: this.state.form.nature
                    })(<Select allowClear
                      placeholder="请选择内容"
                      onChange={(event) => { this.handleSelectChange(event, "nature") }}
                    >
                      {
                        this.state.natureList.map(element => {
                          return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                  {/* <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.nature}
                    onChange={(event) => { this.handleSelectChange(event, "nature") }}
                  >
                    {
                      this.state.natureList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='合同名称' labelAlign="right">
                  {
                    getFieldDecorator('theContract', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.theContract
                    })(<Input allowClear style={{ width: '100%' }} placeholder="请输入名称" onChange={(event) => { this.change(event, "theContract") }} />)
                  }

                </Form.Item>
              </Col>
              <Col span={11} offset={2}>

                <Form.Item label='合同期限' labelAlign="right">
                  {
                    getFieldDecorator('term', {

                      initialValue: this.state.form.term
                    })(<Select allowClear
                      placeholder="请选择内容"
                      onChange={(event) => { this.handleSelectChange(event, "term") }}
                    >
                      {
                        this.state.termList.map(element => {
                          return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                  {/* <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.term}
                    onChange={(event) => { this.handleSelectChange(event, "term") }}
                  >
                    {
                      this.state.termList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='关键词1' labelAlign="right">
                  {
                    getFieldDecorator('keywords1', {
                      initialValue: this.state.form.keywords1
                    })(<Input allowClear style={{ width: '100%' }} placeholder="请输入内容" onChange={(event) => { this.change(event, "keywords1") }} />)
                  }
                  {/* <Input allowClear style={{ width: '100%' }} placeholder="请输入" value={this.state.form.keywords1} onChange={(event) => { this.change(event, "keywords1") }} /> */}
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='合同重要性' labelAlign="right">
                  {
                    getFieldDecorator('importance', {
                      initialValue: this.state.form.importance
                    })(<Select allowClear
                      placeholder="请选择内容"
                      onChange={(event) => { this.handleSelectChange(event, "importance") }}
                    >
                      {
                        this.state.importanceList.map(element => {
                          return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                  {/* <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.importance}
                    onChange={(event) => { this.handleSelectChange(event, "importance") }}
                  >
                    {
                      this.state.importanceList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='关键词2' labelAlign="right">
                  {
                    getFieldDecorator('keywords2', {
                      initialValue: this.state.form.keywords2
                    })(<Input allowClear style={{ width: '100%' }} placeholder="请输入内容" onChange={(event) => { this.change(event, "keywords2") }} />)
                  }
                  {/* <Input allowClear style={{ width: '100%' }} placeholder="请输入" value={this.state.form.keywords2} onChange={(event) => { this.change(event, "keywords2") }} /> */}
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='合同修改性质' labelAlign="right">
                  {
                    getFieldDecorator('modification', {
                      initialValue: this.state.form.modification
                    })(<Select allowClear
                      mode='multiple'
                      placeholder="请选择内容"
                      maxTagCount={4}
                      onChange={(event) => { this.handleSelectChange(event, "modification") }}
                    >
                      {
                        this.state.modificationList.map(element => {
                          return <Option value={element.Title} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                  {/* <Input allowClear style={{ width: '100%' }} placeholder="请输入" /> */}
                </Form.Item>
              </Col>
              <Col span={11} >
                <Form.Item label='我方' labelAlign="right">
                  {
                    getFieldDecorator('we', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.we
                    })(
                      <Select allowClear
                        onChange={(event) => { this.handleSelectChange(event, "we") }}
                        placeholder="请选择"
                        disabled={this.state.currentForm && this.state.form.contract.indexOf('DUMY') === -1 ? true : false}
                      >
                        {
                          this.state.weList.map(element => {
                            return <Option value={element.Title} key={element.Title}>{element.Title}</Option>
                          })
                        }
                      </Select>
                      // <Input allowClear placeholder="请输入内容" onBlur={(event) => { this.onBlurs(event) }} style={{ textTransform: 'uppercase' }} onChange={(event) => { this.change(event, "we") }} disabled={this.state.wedisabled} />
                    )
                  }
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='资质' labelAlign="right">
                {
                    getFieldDecorator('qualifications', {
                      initialValue: this.state.form.qualifications
                    })(
                      <Select allowClear
                        placeholder="请选择"
                        value={this.state.form.qualifications}
                        onChange={(event) => { this.handleSelectChange(event, "qualifications") }}
                      >
                        {
                          this.state.qualificationsList.map(element => {
                            return <Option value={element} key={element}>{element}</Option>
                          })
                        }
                      </Select>
                      )
                  }
                 
                </Form.Item>
              </Col>
              <Col span={11} >
                <Form.Item label='相对方' labelAlign="right">
                  {
                    getFieldDecorator('otherSide', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.otherSide
                    })(<Input onChange={(event) => { this.change(event, "otherSide") }} allowClear style={{ width: '100%' }} placeholder="请输入内容" />)
                  }

                </Form.Item>

              </Col>

              <Col span={11} offset={2}>
                <Form.Item label='审核意见书' labelAlign="right">
                {
                    getFieldDecorator('proposal', {
                      initialValue: this.state.form.proposal
                    })( <Select allowClear
                      placeholder="请选择"
                      value={this.state.form.proposal}
                      onChange={(event) => { this.handleSelectChange(event, "proposal") }}
                    >
                      <Option value='有' >有</Option>
                      <Option value='无' >无</Option>
                    </Select>)
                  }
                  
                </Form.Item>

              </Col>


              <Col span={11}>
                <Form.Item label='社内依赖者名' labelAlign="right">
                  {/* {
                    getFieldDecorator('community', {
                      initialValue: this.state.form.community
                    })(<Select  allowClear
                      
                      showSearch
                      placeholder="请选择"
                      onChange={(event, value) => { this.handleSelectChangess(event, value, "community") }}
                      optionFilterProp="children"
                      filterOption={(input, option: any) => {
                        return (Array.isArray(option.props.children) ? option.props.children.join('') : option.props.children).toLowerCase().indexOf(input.toLowerCase()) >= 0
                      }}
                    >
                      {
                        this.state.communityList.map(element => {
                          return <Option value={element.displayName} key={element.companyName}>{element.displayName} 公司:{element.companyName} 部门:{element.department}</Option>
                        })
                      }
                    </Select>)
                  } */}

                  {/* {
                    getFieldDecorator('community', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: true
                        }
                      ],
                      initialValue: this.state.form.community
                    })(<Input allowClear placeholder="请输入内容"
                      onChange={(event) => { this.allowClear(event, "keywords2") }}
                      onBlur={(event) => { this.loseFocus(event, "community") }} />)
                  } */}

                  {
                    getFieldDecorator('community', {
                      initialValue: this.state.form.community
                    })( <Input allowClear placeholder="请输入内容" value={this.state.form.community}
                    onChange={(event) => { this.allowClear(event, "community") }}
                    onBlur={(event) => { this.loseFocus(event, "community") }} />)
                  }
                 


                </Form.Item>
              </Col>


              <Col span={11} offset={2}>
                <Form.Item label='律师审查' labelAlign="right">
                  {
                    getFieldDecorator("examination", {
                      initialValue: this.state.form.examination
                    })(<Select allowClear
                      placeholder="请选择"
                      onChange={(event) => { this.handleSelectChange(event, "examination") }}
                    >
                      {
                        this.state.LawyerList.map(element => {
                          return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  }
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='所属公司' labelAlign="right">
                  {
                    getFieldDecorator('company', {
                      initialValue: this.state.form.company
                    })(<Input allowClear onChange={(event) => { this.change(event, "company") }} style={{ width: '100%' }} placeholder="请输入内容" ></Input>)
                  }

                  {/* <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.ofAffi}
                    onChange={(event) => { this.handleSelectChange(event, "ofAffi") }}>
                    {
                      this.state.ofAffiList.map(element => {
                        return <Option value={element.companyname} key={element.ID}>{element.companyname}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='决裁编号' labelAlign="right">
                  {
                    getFieldDecorator('cutNumber', {
                      initialValue: this.state.form.cutNumber
                    })(<Input onChange={(event) => { this.change(event, "cutNumber") }} allowClear style={{ width: '100%' }} placeholder="请输入" disabled />)
                  }
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='所属部门' labelAlign="right">
                  {
                    getFieldDecorator('department', {
                      initialValue: this.state.form.department
                    })(<Input allowClear onChange={(event) => { this.change(event, "department") }} style={{ width: '100%' }} placeholder="请输入内容" ></Input>)
                  }
                  {/* <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.department}
                    onChange={(event) => { this.handleSelectChange(event, "department") }}>
                    {
                      this.state.departmentList.map(element => {
                        return <Option value={element.Title} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select> */}
                </Form.Item>
              </Col>
              <Col span={11} offset={2}>
                <Form.Item label="审查担当">
                  <Input.Group compact>
                  {
                    getFieldDecorator('reviewOnxuan', {
                      initialValue: this.state.form.reviewOnxuan
                    })(<Select allowClear mode='multiple' placeholder="请选择" style={{ width: '35%' }} value={this.state.form.reviewOnxuan}
                    onChange={(event, value) => { this.handleSelectChanges(event, value, "reviewOnxuan") }} maxTagCount={1}>
                    {
                      this.state.personreviewList.map(element => {
                        return <Option value={element.ID} key={element.Title}>{element.Title}</Option>
                      })
                    }
                  </Select>)
                  }
                    
                    <Input allowClear style={{ width: '65%' }}
                      placeholder="请输入内容" disabled value={this.state.form.reviewOn} />
                  </Input.Group>
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='其他' labelAlign="right">
                  {
                    getFieldDecorator('other', {
                      initialValue: this.state.form.other
                    })(<Input allowClear placeholder="请输入内容" style={{ width: '100%' }} onChange={(event) => { this.change(event, "other") }} />)
                  }
                  {/* <TextArea rows={4} placeholder="请输入" maxLength={99} style={{ width: '100%' }}
                    value={this.state.form.other} onChange={(event) => { this.change(event, "other") }} /> */}
                </Form.Item>

              </Col>
              <Col span={11} offset={2}>
                <Form.Item label='文件保存' labelAlign="right">
                  {
                    getFieldDecorator('file', {
                      initialValue: this.state.form.file
                    })(<Input allowClear onClick={this.getFilds} readOnly />)
                  }
                  {
                    isHavePermission('AddContractVersion/upload') ? <Input allowClear placeholder="附件" multiple value={this.state.fujian} id="fileUploadInput" type="file" name="myfile" style={{ display: "none" }} /> : null
                  }
                  {/* <Input allowClear  value={this.state.form.file} onClick={this.getFilds} readOnly/> */}

                </Form.Item>
              </Col>

            </Row>
          </Form>
          <Modal
            title="合同版本号采番"
            destroyOnClose={true}
            visible={this.state.visible}
            centered={true}
            closable={false}
            footer={null}

          >
            <Form {...layout} className="Formitems">
              <Row>
                <Col span={20}>
                  <Form.Item label='合同编号' labelAlign="right" className="chehsi" style={{ margin: 0 }}>
                    <Input allowClear style={{ width: '65%' }} value={this.state.form.contracts} disabled />
                    <span>-N</span>
                  </Form.Item>
                </Col>
                <Col span={20}>
                  <Form.Item label='合同名称' labelAlign="right" className="chehsi" style={{ margin: 0 }}>
                    <Input allowClear value={this.state.form.theContracts} disabled />
                  </Form.Item>
                </Col>
                <Col span={20}>
                  <Form.Item label='我方' labelAlign="right" className="chehsi" style={{ margin: 0 }}>
                    <Input allowClear value={this.state.form.wes} disabled />
                  </Form.Item>
                </Col>
                <Col span={20}>
                  <Form.Item label='相对方' labelAlign="right" className="chehsi" style={{ margin: 0 }}>
                    <Input allowClear value={this.state.form.otherSides} disabled />
                  </Form.Item>
                </Col>
                <Col span={20}>
                  <Form.Item label='审查担当' labelAlign="right">
                    <Input allowClear value={this.state.form.reviewOns} disabled />
                  </Form.Item>
                </Col>
                <Col span={5} offset={19}>
                  <Form.Item>
                    <Button type="primary" style={{ padding: ' 0 24px' }} onClick={() => {
                      this.setState({
                        visible: false
                      })
                    }}>关闭</Button>
                  </Form.Item>
                </Col>
              </Row>
            </Form>

          </Modal>
        </div>
        </Spin>
        
      </div>
    )

  }
  //合同性质 合同期限 合同重要性 律师审查 审查担当  公司设置  问题 部门列表
  //访问list NaturcontractGUID,ContractperiodGUID,ContractimportanceGUID,LawyerreviewGUID,PersonGUID,CompanysettingsGUID,ProblemGUID,DepartmentlstGUID
  public async getTest() {

    var _that = this
    var param7 = {
      Guid: ListGUID.ReviewOn //审查担当
    };
    let Person = await Api._getModel(param7);
    var param = {
      Guid: ListGUID.ContractNature //合同性质
    };
    let Naturcontract = await Api._getModel(param);

    var param1 = {
      Guid: ListGUID.ContractPeriod //合同期限
    };
    let Contractperiod = await Api._getModel(param1);
    // _that.state.termList = Contractperiod

    var param2 = {
      Guid: ListGUID.ContractImportance //合同重要性
    };
    let Contractimportance = await Api._getModel(param2);
    //_that.state.importanceList = Contractimportance

    var param3 = {
      Guid: ListGUID.LawerReview //律师审查
    };
    let Lawyerreview = await Api._getModel(param3);
    // _that.state.LawyerList = Lawyerreview

    var param4 = {
      Guid: ListGUID.Companies // 公司设置
    };
    let Companysettings = await Api._getModel(param4);
    // let Companysettings = JSON.parse(sessionStorage.getItem('userDataPer')).PermissionCompany
    // _that.state.weList = Companysettings

    var param5 = {
      Guid: ListGUID.Question // 问题
    };
    let Problem = await Api._getModel(param5);
    // _that.state.problemList = Problem

    var param6 = {
      Guid: ListGUID.Departments //部门列表
    };
    let Departmentlst = await Api._getModel(param6);

    var param7 = {
      Guid: ListGUID.ContractReviseNature //修改性质
    };
    let NatureContracts = await Api._getModel(param7);
    Person = !this.state.contractId ? Person.filter(i => !i.Title.includes('-历史')) : Person;
    const userList = JSON.parse(localStorage.getItem('usersList'));
    Person.forEach(async item => {
      // let informationid = await Api.GetUserById(item.ReviewUserId)
      let informationid = userList.filter(i => i.id === item.ReviewUserId)
      if (informationid && informationid.length > 0) {
        item.Title = informationid.Title
      }

      return
    });
    setTimeout(() => {
      this.setState({
        natureList: Naturcontract,
        termList: Contractperiod,
        importanceList: Contractimportance,
        LawyerList: Lawyerreview,
        weList: Companysettings.filter(i => !i.Title.includes('-历史')),
        problemList: Problem,
        personreviewList: Person,
        departmentList: Departmentlst,
        modificationList: NatureContracts
      }, () => {
        if(!this.state.currentForm) {
          this.getcurrentUser()
        }
      })
    }, 300);
    // _that.state.problemList = Departmentlst
  }
  //默认登陆人
  public async getcurrentUser() {
    
    let { form } = this.state;
    //获取当前登录人
    let Loggedby = await Api._getcurrentUser();
    this.state.personreviewList.forEach(element => {
      if (Loggedby.Id === element.ReviewUserId) {
        form.reviewOnxuan = []
        form.reviewOnxuan.push(element.Id)
        form.reviewOn = element.Title
        form.reviewOnxuans = `${element.Id}#${element.Title}`
      }
    });
    this.setState({
      form
    })
    

  }
  Ergodicvalue(array, id) {
    var value = null;
    for (var i = 0; i < array.length; i++) {
      if (array[i].ID == id) {
        value = array[i].Title;
      }
    }
    return value;
  }
  //提交
  public async getSubmit(e,values) {


    if(this.state.currentForm) {
      this.UpdateData(this.state.currentForm.ItemId)
    } else {
      
      if(e === '提交') {
        message.warning('请先匹配合同版本号再提交');
        return
      }
      if(this.state.variable === '草稿') {
        this.AddData()
      }
    }

    /**----------a--------------------------------- 暂时注释 */
    
    // var MinistryJustice = await Api._isLegalDepartment();
    // 
    // var date = new Date
    // var year = date.getFullYear();
    // // var param = {
    // //   Guid: ListGUID.StandingBook, //台账
    // //   Filter: `Title eq '${values.contract}'`
    // // };
    // // var Persons = await Api._getModel(param);
    // let params: any = [
    //   {
    //     logic: "and",
    //     where: [
    //       {
    //         key: 'Title',
    //         filterType: "Eq",
    //         value: values.contract
    //       }
    //     ]
    //   }
    // ];
    // let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
    // let Persons = data.data;
    // if (Persons.length != 0) {
    //   //  添加新合同
    //   var pa = {
    //     Guid: ListGUID.StandingBook,  //变更申请
    //     ItemId: Persons[0].ItemId,
    //     Obj: {
          
    //       Title: values.contract, //合同编号
    //       AcceptTime: values.date ? moment(values.date).format('YYYY-MM-DD') : null,//法务受理日
    //       Language: values.language,//语言
    //       Problem: values.problem,//问题
    //       Contractualproblems: this.Ergodicvalue(this.state.problemList, values.problem),//问题
    //       LastAnswerTime: values.date1 ? moment(values.date1).format('YYYY-MM-DD') : null,//法务最后回答
    //       ContractNatureID: values.nature,//合同性质
    //       ContractNature: this.Ergodicvalue(this.state.natureList, values.nature),//合同性质
    //       ContractName: values.theContract,//合同名称
    //       ContractDeadlineID: values.term,//合同期限
    //       ContractDeadline: this.Ergodicvalue(this.state.termList, values.term),//合同期限
    //       Keyword1: values.keywords1,//关键1
    //       Keyword2: values.keywords2,//关键2
    //       ContractSignificanceID: values.importance,//合同重要性
    //       ContractSignificance: this.Ergodicvalue(this.state.importanceList, values.importance),//合同重要性
    //       ContactEditNature: values.modification.length > 0 ? values.modification.join(';') : undefined,//合同修改性质
    //       Our: values.we, //我方
    //       Counterparty: values.otherSide,//相对方
    //       LawyerReviewID: values.examination,//律师审查
    //       ContractLawyerReview: this.Ergodicvalue(this.state.LawyerList, values.examination),//律师审查
    //       RelierName: values.community,//社内依赖者
    //       BelongsCompany: values.company,//所属公司
    //       ReviewOnID: this.state.form.reviewOnxuans,//审查担当
    //       BelongsDepartment: values.department,//所属部门
    //       FileAddress: values.file,//文件保存路径
    //       Other: values.other,//其它 
    //       HasReviewOpinion: this.state.form.proposal,//申请书
    //       // 有效、草稿、废弃
    //       ContractStatus: this.state.variable,//合同状态
    //       AcceptYear: values.date ? Number(moment(values.date).format('YYYY-MM-DD').substring(0, 4)) : null,//受理日年份
    //       //流水号
    //       SerialNum: values.contract ? Number(values.contract.substring(0, values.contract.lastIndexOf('-')).substr(-3)) : null,
    //       VersionNum: values.contract ? Number(values.contract.split('-')[1]) : null,
    //       Names: this.state.form.enclosurelist.length == 0 ? null : this.state.form.enclosurelist.join(';'),
    //       Qualifications: values.qualifications,//资质
    //     }
    //   };
    //   if (this.state.JudgmentVariable == '废弃') {
    //     if (this.state.variable == '草稿') {
    //       // var param = {
    //       //   Guid: ListGUID.StandingBook, //台账
    //       //   Filter: `ContractStatus eq '草稿' and  AcceptYear eq '${Number(year)}'`
    //       // };
    //       // let Persons = await Api._getModel(param);
    //       let params: any = [
    //         {
    //           logic: "and",
    //           where: [
    //             {
    //               key: 'ContractStatus',
    //               filterType: "Eq",
    //               value: '草稿'
    //             },{
    //               key: 'AcceptYear',
    //               filterType: "Eq",
    //               value: Number(year)
    //             },
    //           ]
    //         }
    //       ];
    //       let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
    //       let Persons = data.data;
    //       if (Persons.length != 0) {
    //         let array = []
    //         Persons.forEach(element => {
    //           array.push({
    //             Title: Number(element.Title.substr(-3)),
    //             conter: element.Title.slice(0, element.Title.length - 3),
    //             ID: element.ItemId
    //           })
    //         });
    //         array.sort(function (a, b) {
    //           return a.Title - b.Title  //正序
    //         })
    //         pa.Obj.Title = array[array.length - 1].conter + this.prefixZero(Number(array[array.length - 1].Title) + 1, 3)
    //         pa.Obj.AcceptYear = Number(year)
    //       } else {
    //         pa.Obj.Title = 'DUMY' + Number(year) + "001"
    //         pa.Obj.AcceptYear = Number(year)
    //       }

    //     }
    //     let parm = {
    //       Guid: pa.Guid,
    //       ItemId: Number(this.state.JudgmentVariableID),
    //       Obj: pa.Obj
    //     }
    //     var UPdeta = await Api._updateData(parm)
    //     parm.Obj['ItemId'] = Number(this.state.JudgmentVariableID)
    //     await dynamicsService.UpdateContract(parm.Obj)
    //     // this.initialization()
    //     // if (MinistryJustice) { locatiupdateon.href = "#/Dashboard" } else {
    //     //   location.href = "#/DocumentLibrary"
    //     // }
    //     return;
    //   }
    //   if (this.state.variable == '草稿') {
    //     // var param = {
    //     //   Guid: ListGUID.StandingBook, //台账
    //     //   Filter: `ContractStatus eq '草稿' and  AcceptYear eq '${Number(year)}'`
    //     // };
    //     // let Persons = await Api._getModel(param);
    //     let params: any = [
    //       {
    //         logic: "and",
    //         where: [
    //           {
    //             key: 'ContractStatus',
    //             filterType: "Eq",
    //             value: '草稿'
    //           },{
    //             key: 'AcceptYear',
    //             filterType: "Eq",
    //             value: Number(year)
    //           },
    //         ]
    //       }
    //     ];
    //     let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
    //     let Persons = data.data;
    //     if (Persons.length != 0) {
    //       let array = []
    //       Persons.forEach(element => {
    //         array.push({
    //           Title: Number(element.Title.substr(-3)),
    //           conter: element.Title.slice(0, element.Title.length - 3),
    //           ID: element.ItemId
    //         })
    //       });
    //       array.sort(function (a, b) {
    //         return a.Title - b.Title  //正序
    //       })
    //       pa.Obj.Title = array[array.length - 1].conter + this.prefixZero(Number(array[array.length - 1].Title) + 1, 3)
    //       pa.Obj.AcceptYear = Number(year)
    //     } else {
    //       pa.Obj.Title = 'DUMY' + Number(year) + "001"
    //       pa.Obj.AcceptYear = Number(year)
    //     }

    //   }
    //   //废弃编号启用
    //   var result = UPdeta = await Api._updateData(pa);
    //   pa.Obj['ItemId'] = Number(Persons[0].ItemId)
    //   await dynamicsService.UpdateContract(pa.Obj)
    //   // this.initialization()
    //   // if (MinistryJustice) { location.href = "#/Dashboard" } else {
    //   //   location.href = "#/DocumentLibrary"
    //   // }
    // } else {
    //   var content = {
    //     Guid: ListGUID.StandingBook,  //变更申请
    //     Obj: {
    //       Title: values.contract, //合同编号
    //       AcceptTime: values.date ? moment(values.date).format('YYYY-MM-DD') : null,//法务受理日
    //       Language: values.language,//语言
    //       Problem: values.problem,//问题
    //       Contractualproblems: this.Ergodicvalue(this.state.problemList, values.problem),//问题
    //       LastAnswerTime: values.date1 ? moment(values.date1).format('YYYY-MM-DD') : null,//法务最后回答
    //       ContractNatureID: values.nature,//合同性质
    //       ContractNature: this.Ergodicvalue(this.state.natureList, values.nature),//合同性质
    //       ContractName: values.theContract,//合同名称
    //       ContractDeadlineID: values.term,//合同期限
    //       ContractDeadline: this.Ergodicvalue(this.state.termList, values.term),//合同期限
    //       Keyword1: values.keywords1,//关键1
    //       Keyword2: values.keywords2,//关键2
    //       ContractSignificanceID: values.importance,//合同重要性
    //       ContractSignificance: this.Ergodicvalue(this.state.importanceList, values.importance),//合同重要性
    //       ContactEditNature: values.modification.length > 0 ? values.modification.join(';') : undefined,//合同修改性质
    //       Our: values.we, //我方
    //       Counterparty: values.otherSide,//相对方
    //       LawyerReviewID: values.examination,//律师审查 
    //       ContractLawyerReview: this.Ergodicvalue(this.state.LawyerList, values.examination),//律师审查
    //       RelierName: values.community,//社内依赖者
    //       BelongsCompany: values.company,//所属公司
    //       ReviewOnID: this.state.form.reviewOnxuans,//审查担当
    //       BelongsDepartment: values.department,//所属部门
    //       FileAddress: values.file,//文件保存路径
    //       Other: values.other,//其它 
    //       HasReviewOpinion: this.state.form.proposal,//申请书
    //       // 有效、草稿、废弃
    //       ContractStatus: this.state.variable,//合同状态
    //       AcceptYear: values.date ? Number(moment(values.date).format('YYYY-MM-DD').substring(0, 4)) : null,//受理日年份
    //       //流水号
    //       SerialNum: values.contract ? Number(values.contract.substring(0, values.contract.lastIndexOf('-')).substr(-3)) : null,
    //       VersionNum: values.contract ? Number(values.contract.split('-')[1]) : null,
    //       Names: this.state.form.enclosurelist.length == 0 ? null : this.state.form.enclosurelist.join(';'),
    //       Qualifications: values.qualifications,//资质
    //     }
    //   };
    //   if (this.state.variable == '草稿') {
    //     // var param = {
    //     //   Guid: ListGUID.StandingBook, //台账
    //     //   Filter: `ContractStatus eq '草稿' and  AcceptYear eq '${Number(year)}' `
    //     // };
    //     // let Persons = await Api._getModel(param);
    //     let params: any = [
    //       {
    //         logic: "and",
    //         where: [
    //           {
    //             key: 'ContractStatus',
    //             filterType: "Eq",
    //             value: '草稿'
    //           },{
    //             key: 'AcceptYear',
    //             filterType: "Eq",
    //             value: Number(year)
    //           },
    //         ]
    //       }
    //     ];
    //     let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
    //     let Persons = data.data;
    //     if (Persons.length != 0) {
    //       let array = []
    //       Persons.forEach(element => {
    //         array.push({
    //           Title: Number(element.Title.substr(-3)),
    //           conter: element.Title.slice(0, element.Title.length - 3),
    //           ID: element.ItemId
    //         })
    //       });
    //       array.sort(function (a, b) {
    //         return a.Title - b.Title  //正序
    //       })
    //       content.Obj.Title = array[array.length - 1].conter + this.prefixZero(Number(array[array.length - 1].Title) + 1, 3)
    //       content.Obj.AcceptYear = Number(year)
    //     } else {
    //       content.Obj.Title = 'DUMY' + Number(year) + "001"
    //       content.Obj.AcceptYear = Number(year)
    //     }
    //     
    //     let result = await Api._saveaddDataGuid(content);
    //     pa.Obj['AuthorId'] = this.state.AuthorId;
    //     pa.Obj['AuthorName'] = this.state.AuthorName;
    //     pa.Obj['ItemId'] = result.data.ID;
    //     await dynamicsService.AddContract(content.Obj)
    //     // this.initialization()
    //     // if (MinistryJustice) { location.href = "#/Dashboard" } else {
    //     //   location.href = "#/DocumentLibrary"
    //     // }
    //   }
    // }
     /**------------------------------------------- 暂时注释 */
  }
    // 更新数据
    UpdateData = async (id) => {
      
      this.setState({
        loading: true
      })
      let parm = {
        Guid: ListGUID.StandingBook,
        ItemId: id,
        Obj: {
          Title: this.state.form.contract, //合同编号
          AcceptTime: this.state.form.date ? moment(this.state.form.date).format('YYYY-MM-DD') : null,//法务受理日
          Language: this.state.form.language,//语言
          Problem: this.state.form.problem,//问题
          Contractualproblems: this.Ergodicvalue(this.state.problemList, this.state.form.problem),//问题
          LastAnswerTime: this.state.form.date1 ? moment(this.state.form.date1).format('YYYY-MM-DD') : null,//法务最后回答
          ContractNatureID: this.state.form.nature,//合同性质
          ContractNature: this.Ergodicvalue(this.state.natureList, this.state.form.nature),//合同性质
          ContractName: this.state.form.theContract,//合同名称
          ContractDeadlineID: this.state.form.term,//合同期限
          ContractDeadline: this.Ergodicvalue(this.state.termList, this.state.form.term),//合同期限
          Keyword1: this.state.form.keywords1,//关键1
          Keyword2: this.state.form.keywords2,//关键2
          ContractSignificanceID: this.state.form.importance,//合同重要性
          ContractSignificance: this.Ergodicvalue(this.state.importanceList, this.state.form.importance),//合同重要性
          ContactEditNature: this.state.form.modification.length > 0 ? this.state.form.modification.join(';') : undefined,//合同修改性质
          Our: this.state.form.we, //我方
          Counterparty: this.state.form.otherSide,//相对方
          LawyerReviewID: this.state.form.examination,//律师审查
          ContractLawyerReview: this.Ergodicvalue(this.state.LawyerList, this.state.form.examination),//律师审查
          RelierName: this.state.form.community,//社内依赖者
          BelongsCompany: this.state.form.company,//所属公司
          ReviewOnID: this.state.form.reviewOnxuans,//审查担当
          BelongsDepartment: this.state.form.department,//所属部门
          // FileAddress: this.state.form.file,//文件保存路径
          Other: this.state.form.other,//其它 
          HasReviewOpinion: this.state.form.proposal,//申请书
          // 有效、草稿、废弃
          ContractStatus: this.state.variable,//合同状态
          AcceptYear: this.state.form.date ? Number(moment(this.state.form.date).format('YYYY-MM-DD').substring(0, 4)) : null,//受理日年份
          //流水号
          SerialNum: this.state.form.contract ? Number(this.state.form.contract.substring(0, this.state.form.contract.lastIndexOf('-')).substr(-3)) : null,
          VersionNum: this.state.form.contract ? Number(this.state.form.contract.split('-')[1]) : null,
          // Names: this.state.form.enclosurelist.length == 0 ? null : this.state.form.enclosurelist.join(';'),
          Qualifications: this.state.form.qualifications,//资质
        }
      }
      // await Api._updateData(parm)
      parm.Obj['AuthorName'] = this.state.AuthorName;
      parm.Obj['ItemId'] = id;
      let response = await dynamicsService.UpdateContract(parm.Obj)
      let reviewOnxuan = []
      let reviewOn = []
      if(response.code === 200) {
        if (response.data.ReviewOnID != null) {
          if (response.data.ReviewOnID.indexOf(';') != -1) {
            let arrays = response.data.ReviewOnID.split(';')
            for (let i = 0; arrays.length > i; i++) {
              reviewOnxuan.push(Number(arrays[i].split('#')[0]))
              reviewOn.push(arrays[i].split('#')[1])
            }
          } else {
            reviewOnxuan.push(Number(response.data.ReviewOnID.split('#')[0]))
            reviewOn.push(response.data.ReviewOnID.split('#')[1])
          }
        }
        let form = {
          contract: response.data.Title,
          date: response.data.AcceptTime == null ? null : moment(response.data.AcceptTime),
          date1: response.data.LastAnswerTime == null ? null : moment(response.data.LastAnswerTime),
          otherSide: response.data.Counterparty,
          text: response.data.Our,
          theContract: response.data.ContractName,
          language: response.data.Language,//语言
          problem: response.data.Problem,//问题
          nature: response.data.ContractNatureID,//合同性质
          term: response.data.ContractDeadlineID,//合同期限
          keywords1: response.data.Keyword1,//关键1
          keywords2: response.data.Keyword2,//关键2
          importance: response.data.ContractSignificanceID,//合同重要性
          modification: response.data.ContactEditNature ? response.data.ContactEditNature.split(';') : [],//合同修改性质
          we: response.data.Our, //我方
          qualifications: response.data.Qualifications  || '无',//资质
          examination: response.data.LawyerReviewID  || 1,//律师审查 
          community: response.data.RelierName,//社内依赖者
          company: response.data.BelongsCompany,//所属公司
          reviewOnxuans: response.data.ReviewOnID,//审查担当
          department: response.data.BelongsDepartment,//所属部门
          file: response.data.FileAddress,//文件保存路径
          other: response.data.Other,//其它 
          proposal: response.data.HasReviewOpinion || '无',//申请书
          reviewOnxuan: reviewOnxuan,
          reviewOn: reviewOn,
          contracts:response.data.Title.substring(0, response.data.Title.lastIndexOf('-')),
          // enclosurelist: response.data.Names == null ? [] : response.data.Names.split(';'),
          cutNumber: response.data.RuleNumber
        }
        this.setState({
          form
        })
        this.setState({
          currentForm: response.data
        })
      } else {
        message.warning(response.msg)
      }
      this.props.form.setFieldsValue({
        contract: response.title
      })
      this.setState({
       
        loading: false
      })
    }
    // 新增数据
    AddData = async () => {
      
      this.setState({
        loading: true
      })
      let parm = {
        Guid: ListGUID.StandingBook,
        Obj: {
          Title: this.state.form.contracts, //合同编号
          AcceptTime: this.state.form.date ? moment(this.state.form.date).format('YYYY-MM-DD') : null,//法务受理日
          Language: this.state.form.language,//语言
          Problem: this.state.form.problem,//问题
          Contractualproblems: this.Ergodicvalue(this.state.problemList, this.state.form.problem),//问题
          LastAnswerTime: this.state.form.date1 ? moment(this.state.form.date1).format('YYYY-MM-DD') : null,//法务最后回答
          ContractNatureID: this.state.form.nature,//合同性质
          ContractNature: this.Ergodicvalue(this.state.natureList, this.state.form.nature),//合同性质
          ContractName: this.state.form.theContract,//合同名称
          ContractDeadlineID: this.state.form.term,//合同期限
          ContractDeadline: this.Ergodicvalue(this.state.termList, this.state.form.term),//合同期限
          Keyword1: this.state.form.keywords1,//关键1
          Keyword2: this.state.form.keywords2,//关键2
          ContractSignificanceID: this.state.form.importance,//合同重要性
          ContractSignificance: this.Ergodicvalue(this.state.importanceList, this.state.form.importance),//合同重要性
          ContactEditNature: this.state.form.modification && this.state.form.modification.length > 0 ? this.state.form.modification.join(';') : undefined,//合同修改性质
          Our: this.state.form.we, //我方
          Counterparty: this.state.form.otherSide,//相对方
          LawyerReviewID: this.state.form.examination,//律师审查
          ContractLawyerReview: this.Ergodicvalue(this.state.LawyerList, this.state.form.examination),//律师审查
          RelierName: this.state.form.community,//社内依赖者
          BelongsCompany: this.state.form.company,//所属公司
          ReviewOnID: this.state.form.reviewOnxuans,//审查担当
          BelongsDepartment: this.state.form.department,//所属部门
          Other: this.state.form.other,//其它 
          HasReviewOpinion: this.state.form.proposal,//申请书
          // 有效、草稿、废弃
          ContractStatus: this.state.variable || '有效',//合同状态
          AcceptYear: this.state.form.date ? Number(moment(this.state.form.date).format('YYYY-MM-DD').substring(0, 4)) : null,//受理日年份
          //流水号
          SerialNum: this.state.form.contract ? Number(this.state.form.contract.substring(0, this.state.form.contract.lastIndexOf('-')).substr(-3)) : null,
          VersionNum: this.state.form.contract ? Number(this.state.form.contract.split('-')[1]) : null,
          // Names: this.state.form.enclosurelist.length == 0 ? null : this.state.form.enclosurelist.join(';'),
          Qualifications: this.state.form.qualifications,//资质
        }
      }
      parm.Obj['AuthorId'] = this.state.AuthorId;
      parm.Obj['AuthorName'] = this.state.AuthorName;
      let response = await dynamicsService.AddContract(parm.Obj)
      let reviewOnxuan = []
      let reviewOn = []
      
      
      if(response.code === 200) {
        if (response.data.ReviewOnID != null) {
          if (response.data.ReviewOnID.indexOf(';') != -1) {
            let arrays = response.data.ReviewOnID.split(';')
            for (let i = 0; arrays.length > i; i++) {
              reviewOnxuan.push(Number(arrays[i].split('#')[0]))
              reviewOn.push(arrays[i].split('#')[1])
            }
          } else {
            reviewOnxuan.push(Number(response.data.ReviewOnID.split('#')[0]))
            reviewOn.push(response.data.ReviewOnID.split('#')[1])
          }
        }
        let form = {
          contract: response.data.Title,
          date: response.data.AcceptTime == null ? null : moment(response.data.AcceptTime),
          date1: response.data.LastAnswerTime == null ? null : moment(response.data.LastAnswerTime),
          otherSide: response.data.Counterparty,
          text: response.data.Our,
          theContract: response.data.ContractName,
          language: response.data.Language,//语言
          problem: response.data.Problem,//问题
          nature: response.data.ContractNatureID,//合同性质
          term: response.data.ContractDeadlineID,//合同期限
          keywords1: response.data.Keyword1,//关键1
          keywords2: response.data.Keyword2,//关键2
          importance: response.data.ContractSignificanceID,//合同重要性
          modification: response.data.ContactEditNature ? response.data.ContactEditNature.split(';') : [],//合同修改性质
          we: response.data.Our, //我方
          qualifications: response.data.Qualifications || '无',//资质
          examination: response.data.LawyerReviewID  || 1,//律师审查 
          community: response.data.RelierName,//社内依赖者
          company: response.data.BelongsCompany,//所属公司
          reviewOnxuans: response.data.ReviewOnID,//审查担当
          department: response.data.BelongsDepartment,//所属部门
          file: response.data.FileAddress,//文件保存路径
          other: response.data.Other,//其它 
          proposal: response.data.HasReviewOpinion  || '无',//申请书
          reviewOnxuan: reviewOnxuan,
          reviewOn: reviewOn,
          contracts:response.data.Title.substring(0, response.data.Title.lastIndexOf('-')),
          // enclosurelist: response.data.Names == null ? [] : response.data.Names.split(';'),
          cutNumber: response.data.RuleNumber
        }
        this.setState({
          form: form,
          JudgmentVariable: this.state.JudgmentVariableID != null ? this.state.JudgmentVariable : '有效',
          wedisabled: true,
          loading: false
        })
        this.props.form.setFieldsValue({
          contract: response.data.Title
        })
        this.setState({
          currentForm: response.data
        })
      } else {
        this.setState({
          loading: false
        })
        message.warning(response.msg);
      }
      
    }
  //生成编号
  private generateNumber = async (e) => {
    this.setState({
      variable: '有效'
    }, () => {
      e.preventDefault();
      this.props.form.validateFields(['contract'], async (err, values) => {
        
        if (!err) {
          if(this.state.currentForm) {
            if(!this.state.currentForm.Title.includes('DUMY')) {
              this.AddData()
            } else {
              this.UpdateData(this.state.currentForm.ItemId)
            }
            
          } else {
            this.AddData()
          }
          /**------------------------------------------------- 暂时 */
          // let params = []
          // params.push(new CamlParam("Title", this.state.form.contracts, SPDataType.Text, CAMLCompare.Contains));
          // params.push(new CamlParam("ContractStatus", '废弃', SPDataType.Text, CAMLCompare.Eq));
          // params.push(new CamlParam("VersionNum", '0', SPDataType.Number, CAMLCompare.Neq));
          // let camlQuery = {
          //   ViewXml: ''
          // }
          // //不排序
          // let demo = Api.buildCamlXml(params);
          // let Guid = ListGUID.StandingBook //根据条件检索表数据
          // camlQuery.ViewXml = demo
          // let Persons = await Api.GetListItemsByCAMLQuery(Guid, camlQuery);
          // 
          // // var param = {
          // //   Guid: ListGUID.StandingBook, //台账
          // //   Filter: `substringof('${this.state.form.contracts}',Title)  and  ContractStatus eq '废弃' and VersionNum Gt 0`
          // // };
          // // let Persons = await Api._getModel(param);

          // if (Persons.length != 0) {
          //   let array = []
          //   Persons.forEach(element => {
          //     array.push({
          //       Titles: element.Title,
          //       FileAddress: element.FileAddress,
          //       Title: Number(element.Title.split('-')[1]),
          //       ID: element.ID
          //     })
          //   });
          //   array.sort(function (a, b) {
          //     return a.Title - b.Title  //正序
          //   })
          //   //获取废弃的编号
          //   let { form } = this.state;
          //   let reviewOnxuan = []
          //   let reviewOn = []
          //   if (this.state.datas.ReviewOnID != null) {
          //     if (this.state.datas.ReviewOnID.indexOf(';') != -1) {
          //       let arrays = this.state.datas.ReviewOnID.split(';')
          //       for (let i = 0; arrays.length > i; i++) {
          //         reviewOnxuan.push(Number(arrays[i].split('#')[0]))
          //         reviewOn.push(arrays[i].split('#')[1])
          //       }
          //     } else {
          //       reviewOnxuan.push(Number(this.state.datas.ReviewOnID.split('#')[0]))
          //       reviewOn.push(this.state.datas.ReviewOnID.split('#')[1])
          //     }
          //   }
          //   form.reviewOnxuan = reviewOnxuan
          //   form.reviewOn = reviewOn
          //   form.reviewOnxuans = this.state.datas.ReviewOnID
          //   form.proposal = '无'
          //   this.props.form.setFieldsValue({
          //     contract: array[0].Titles, //编号
          //     theContract: this.state.datas.ContractName,//合同名称
          //     nature: this.state.datas.ContractNatureID,//合同性质
          //     we: this.state.datas.Our,//我方
          //     otherSide: this.state.datas.Counterparty,//相对方
          //     importance: this.state.datas.ContractSignificanceID,//合同重要性
          //     examination: this.state.datas.LawyerReviewID,//律师审查
          //     file: array[0].FileAddress,//文件保存
          //     reviewOnxuans: this.state.datas.ReviewOnID,//审查担当
          //   });

          //   setTimeout(() => {
          //     this.Folder(this.state.datas.Our, this.state.datas.AcceptTime.substring(0, 4), this.state.form.contracts + '-' + (Number(array[0].Title)))
          //     this.setState({
          //       form,
          //       disabled: true,
          //       pidisabled: true,
          //       JudgmentVariableID: this.state.wedisabled ? this.state.JudgmentVariableID : array[0].ID,
          //       JudgmentVariable: this.state.wedisabled ? this.state.JudgmentVariable : '废弃'
          //     })

          //   }, 100);

          //   return;
          // }
          // let param = []
          // param.push(new CamlParam("Title", this.state.form.contracts, SPDataType.Text, CAMLCompare.Contains));
          // param.push(new CamlParam("ContractStatus", '有效', SPDataType.Text, CAMLCompare.Eq));
          // let camlQuerys = {
          //   ViewXml: ''
          // }
          // //不排序
          // let demos = Api.buildCamlXml(param);
          // let Guids = ListGUID.StandingBook //根据条件检索表数据
          // camlQuerys.ViewXml = demos
          // let Person = await Api.GetListItemsByCAMLQuery(Guids, camlQuerys);
          // 
          // //   Guid: ListGUID.StandingBook, //台账
          // //   Filter: `substringof('${this.state.form.contracts}',Title) and  ContractStatus eq '有效'`
          // // };
          // // let Person = await Api._getModel(param1);
          // if (Person.length != 0) {
          //   let array = []
          //   Person.forEach(element => {
          //     array.push({
          //       Title: Number(element.Title.split('-')[1]),
          //       ID: element.ID
          //     })
          //   });
          //   array.sort(function (a, b) {
          //     return a.Title - b.Title  //正序
          //   })

          //   let { form } = this.state;
          //   let reviewOnxuan = []
          //   let reviewOn = []
          //   if (this.state.datas.ReviewOnID) {
          //     let arrays = this.state.datas.ReviewOnID.split(';')
          //     for (let i = 0; arrays.length > i; i++) {
          //       reviewOnxuan.push(Number(arrays[i].split('#')[0]))
          //       reviewOn.push(arrays[i].split('#')[1])
          //     }
          //   }
          //   form.reviewOnxuan = reviewOnxuan
          //   form.reviewOn = reviewOn
          //   form.reviewOnxuans = this.state.datas.ReviewOnID
          //   form.proposal = '无'
          //   this.props.form.setFieldsValue({
          //     contract: this.state.form.contracts + '-' + (Number(array[array.length - 1].Title) + 1), //编号
          //     theContract: this.state.datas.ContractName,//合同名称
          //     nature: this.state.datas.ContractNatureID,//合同性质
          //     we: this.state.datas.Our,//我方
          //     otherSide: this.state.datas.Counterparty,//相对方
          //     importance: this.state.datas.ContractSignificanceID,//合同重要性
          //     examination: this.state.datas.LawyerReviewID,//律师审查
          //     file: this.state.datas.AcceptTime.substring(0, 4) + '/' + this.state.datas.Our + '/' + this.state.form.contracts + '-' + (Number(array[array.length - 1].Title) + 1) + '/',//文件保存
          //     reviewOnxuans: this.state.datas.ReviewOnID,//审查担当
          //     ContractStatus: '有效',//合同状态
          //   })

          //   setTimeout(async () => {
          //     this.Folder(this.state.datas.Our, this.state.datas.AcceptTime.substring(0, 4), this.state.form.contracts + '-' + (Number(array[array.length - 1].Title) + 1))
          //     this.setState({
          //       form,
          //       disabled: true,
          //       pidisabled: true,
          //       JudgmentVariable: this.state.wedisabled ? this.state.JudgmentVariable : '有效'
          //     })
          //     //创建合同编号
          //     let pa = {
          //       Guid: ListGUID.StandingBook,  //变更申请
          //       Obj: {
          //         Title: this.state.form.contracts + '-' + (Number(array[array.length - 1].Title) + 1), //合同编号
          //         ContractName: this.state.datas.ContractName,//合同名称
          //         ContractNatureID: this.state.datas.ContractNatureID,//合同性质
          //         Our: this.state.datas.Our, //我方
          //         Counterparty: this.state.datas.Counterparty,//相对方
          //         ContractSignificanceID: this.state.datas.ContractSignificanceID,//合同重要性
          //         LawyerReviewID: this.state.datas.LawyerReviewID,//律师审查
          //         ReviewOnID: this.state.datas.ReviewOnID,//审查担当
          //         HasReviewOpinion: this.state.form.proposal,//申请书
          //         VersionNum: (Number(array[array.length - 1].Title) + 1),
          //         FileAddress: this.state.datas.AcceptTime.substring(0, 4) + '/' + this.state.datas.Our + '/' + this.state.form.contracts + '-' + (Number(array[array.length - 1].Title) + 1) + '/',//文件保存路径
          //         ContractStatus: '有效',
          //       }
          //     };
          //     
          //     let result = await Api._saveaddDataGuid(pa);
          //     pa.Obj['AuthorId'] = this.state.AuthorId;
          //     pa.Obj['AuthorName'] = this.state.AuthorName;
          //     pa.Obj['ItemId'] = result.data.ID;
          //     await dynamicsService.AddContract(pa.Obj)
          //   }, 100);
          //   return;
          // }
          /** --------------------------------------------------------- 暂时 */
        }
      });
    })
    


  }
  //根据编号获取 数据 更新
  public async getedit(item) {
    
    // var param = {
    //   Guid: ListGUID.StandingBook, //dit
    //   Filter: `Title eq '${item}'`
    // };
    // let Persons = await Api._getModel(param);edit
    this.setState({
      loading: true
    })
    let params: any = [
      {
        logic: "and",
        where: [
          {
            key: 'Title',
            filterType: "Eq",
            value: item
          }
        ]
      }
    ];
    let data = await Api._getPaged2({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: params })
    let Persons = data.data;
    let reviewOnxuan = []
    let reviewOn = []
    if (Persons && Persons.length > 0 && Persons[0].ReviewOnID != null) {
      if (Persons[0].ReviewOnID.indexOf(';') != -1) {
        let arrays = Persons[0].ReviewOnID.split(';')
        for (let i = 0; arrays.length > i; i++) {
          reviewOnxuan.push(Number(arrays[i].split('#')[0]))
          reviewOn.push(arrays[i].split('#')[1])
        }
      } else {
        reviewOnxuan.push(Number(Persons[0].ReviewOnID.split('#')[0]))
        reviewOn.push(Persons[0].ReviewOnID.split('#')[1])
      }
    }
    
    await this.setState({
      form: {
        contract: Persons[0].Title,
        date: Persons[0].AcceptTime == null ? null : moment(Persons[0].AcceptTime),
        date1: Persons[0].LastAnswerTime == null ? null : moment(Persons[0].LastAnswerTime),
        otherSide: Persons[0].Counterparty,
        text: Persons[0].Our,
        theContract: Persons[0].ContractName,
        language: Persons[0].Language,//语言
        problem: Persons[0].Problem,//问题
        nature: Persons[0].ContractNatureID,//合同性质
        term: Persons[0].ContractDeadlineID,//合同期限
        keywords1: Persons[0].Keyword1,//关键1
        keywords2: Persons[0].Keyword2,//关键2
        importance: Persons[0].ContractSignificanceID,//合同重要性
        modification: Persons[0].ContactEditNature ? Persons[0].ContactEditNature.split(';') : [],//合同修改性质
        we: Persons[0].Our, //我方
        qualifications: Persons[0].Qualifications,//资质
        examination: Persons[0].LawyerReviewID,//律师审查 
        community: Persons[0].RelierName,//社内依赖者
        company: Persons[0].BelongsCompany,//所属公司
        reviewOnxuans: Persons[0].ReviewOnID,//审查担当
        department: Persons[0].BelongsDepartment,//所属部门
        file: Persons[0].FileAddress,//文件保存路径
        other: Persons[0].Other,//其它 
        proposal: Persons[0].HasReviewOpinion,//申请书
        reviewOnxuan: reviewOnxuan,
        reviewOn: reviewOn,
        enclosurelist: Persons[0].Names == null ? [] : Persons[0].Names.split(';'),
        cutNumber: Persons[0].RuleNumber
      },
      JudgmentVariableID: Persons[0].ItemId,
      JudgmentVariable: '废弃',
      currentForm: Persons[0],
      wedisabled: true,
      disabled: true,
      loading: false
    })
    
    await dynamicsService.UpdateListFileNames({dataid: Persons[0].id, listguid: ListGUID.StandingBook, fileaddress: Persons[0].FileAddress})
  }
  public prefixZero(n, m) {
    var _a = (Array(m).join('0') + n).slice(-m);
    return _a;
  }
  public async Folder(A, B, C) {
    let Persons2 = await Api.checkAndCreateFolder(`${ListGUID.ContractLibRelativeUrl}/${B}`)
    let Persons3 = await Api.checkAndCreateFolder(`${ListGUID.ContractLibRelativeUrl}/${B}/${A}`)
    let Persons4 = await Api.checkAndCreateFolder(`${ListGUID.ContractLibRelativeUrl}/${B}/${A}/${C}`)
  }
}
export default Form.create()(AddContractVersion);